<template>
  <div>
    <h2>测试动态组件</h2>
    <hr>
    <keep-alive>
      <component :is="currentComponent" v-bind="obj">点击</component>
    </keep-alive>
    <button @click="handleClick">点击</button>
  </div>
</template>
<script>
import MyMsg from './MyMsg.vue'

export default {
  name: 'Mytest',
  components: { MyMsg },
  data() {
    return {
      currentComponent: 'a',
      obj: {
        href: 'http://itcast.cn',
        class: 'active'
      }
    }
  },
  methods: {
    handleClick() {
      this.currentComponent = 'MyMsg'
    }
  }
}
</script>
